﻿using Batman.Core;
using Batman.DLL.UserModule.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Batman.Web.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class UsersController : ControllerBase
    {
        UserManager<User> UserManager;

        public UsersController(UserManager<User> userManager)
        {
            UserManager = userManager;
        }

        public IActionResult Get(int maxResult = 10, int skipCount = 0)
        {
            var query = UserManager.Users.Skip(skipCount).Take(maxResult);
            var total = query.Count();
            var data = query.ToList();

            data.ForEach(d => d.PasswordHash = null);

            var result = PagedResponse.New(total, data);

            return new JsonResult(result);
        }
    }

}
